<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="common/include :: header('员工列表')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<!--模块一,用于数据的高级查询-->
			<div class="col-sm-12 search-collapse">
				<form id="serviceItem-form">
					<div class="select-list">
						<ul>
							<li>
								关键字：<input type="text" name="checkName" placeholder="请输入名字或者邮箱"/>
							</li>
							<li>
								是否是超管：
								<select name="admin" th:with="type=${@dict.getType('si_car_package')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
								</select>
							</li>
							<li>
								是否冻结：
								<select name="status" th:with="type=${@dict.getType('si_car_package')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
								</select>
							</li>
							<li>
								所在部门:
								<select name="department">
									<option value="">所有</option>
									<option th:each="department:${departments}"
											th:text="${department.name}"
										th:value="${department.id}"
									></option>
								</select>
							</li>
							<li>
								<div class="col-sm-4">
									<div class="input-group date">
										<input name="startDateTime" class="form-control queryTime" placeholder="开始时间" type="text" required>
										<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
										<input name="endDateTime" class="form-control queryTime" placeholder="结束时间" type="text" required>
										<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
									</div>
								</div>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

			<!--模块二,新增,修改,删除,导出的四个按钮-->
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="business:serviceItem:add">
	                <i class="fa fa-plus"></i> 新增
	            </a>
	        </div>

			<!--表格模块,使用了异步刷新的前端框架bootstrap-table-->
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
		<div id="permissionModel" class="modal fade" tabindex="-1" role="dialog">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title">部门信息</h4>
					</div>
					<form action="/permission/saveOrUpdate" method="post">
						<input type="hidden" name="id" id="id">
						<div class="modal-body">
							<div class="form-group">
								<label for="name">部门名称</label>
								<span class="form-control" name="name" id="name"></span>
							</div>
							<div class="form-group">
								<label for="sn">部门缩写</label>
								<span  class="form-control" name="sn" id="sn"></span>
							</div>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">确定</button>
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<th:block th:include="common/include :: footer" />
	<th:block th:include="common/include :: datetimepicker"/>
	<script th:inline="javascript">
		var userSexDates = [[${@dict.getType('sys_user_sex')}]];
		var prefix = ctx + "/business/employee";
		$(function() {
		    var options = {
		        url: prefix + "/query",						//查询的url路径
		        createUrl: prefix + "/addPage",				//新增的url
		        updateUrl: prefix + "/editPage?id={id}",	//编辑的url 携带了id
		        exportUrl: prefix + "/export",				//导入的url
				removeUrl: prefix + "/remove",
				uniqueId:"id",
				sortName: "seq",
				modalName: "员工",
		        columns: [{
		            checkbox: true						//在表格前面加入了复选框
		        },
					{
						field: 'status',
						title: '是否冻结',
						visible: false						//设为false表示隐藏id列,在页面上不做显示
					},
		        {
		            field: 'id',
		            title: '员工id',
					visible: false						//设为false表示隐藏id列,在页面上不做显示
		        },
		        {
		            field: 'name',
		            title: '姓名',
		            sortable: true
		        },
				{
					field: 'email',
					title: '邮箱',
					sortable: true
				},
				{
					field: 'age',
					title: '年龄',
					sortable: true
				},
				{
					field: 'sex',
					title: '性别',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(userSexDates, value);
					}
				},
					{
						field: 'hiredate',
						title: '入职时间',
						sortable: true
					},
				{
					field: 'admin',
					title: '是否是超管',
					sortable: true,
					formatter: function(value, row, index) {
						return value ? '是' : '否'
					}
				},
				{
					field: 'dept.name',
					title: '所在部门',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" ' +
								'onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');

						actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="detail(\'' + row.id + '\')"><i class="fa fa-list-ul"></i>查看部门详情</a> ');

						actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)"' +
									' onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
		                return actions.join(' ');
		            }
		        }]
		    };
		    $.table.init(options);
		});
		$(".queryTime").datetimepicker({
			format: "yyyy-mm-dd hh:ii",
			autoclose: true
		});
		function detail(id) {
				var rs = $('#bootstrap-table').bootstrapTable('getRowByUniqueId',id);
			$('#name').html(rs.dept.name);
			$('#sn').html(rs.dept.sn);
				$('#permissionModel').modal('show');
		}
	</script>
</body>
</html>